package com.ruoyi.questionnaire.util;

import cn.hutool.core.util.IdUtil;

/**
 * 雪花ID工具类
 */
public class SnowflakeIdUtil {
    // 可根据实际部署情况调整workerId和datacenterId
    private static final long WORKER_ID = 1L;
    private static final long DATACENTER_ID = 1L;
    private static final cn.hutool.core.lang.Snowflake SNOWFLAKE = IdUtil.getSnowflake(WORKER_ID, DATACENTER_ID);

    /**
     * 获取全局唯一雪花ID
     */
    public static long nextId() {
        return SNOWFLAKE.nextId();
    }

    /**
     * 获取全局唯一雪花ID字符串
     */
    public static String nextIdStr() {
        return SNOWFLAKE.nextIdStr();
    }
} 